package com.itheima.Example;
// 猜数游戏

import java.util.Random;
import java.util.Scanner;

public class ExampleDemo2 {
    public static void main(String[] args) {
        test();
    }

    public static void test() {
        Random r = new Random();
        int number = r.nextInt(100) + 1; // 1-100的随机数
        Scanner sc = new Scanner(System.in);
        int a = 0;
        do {
            System.out.println("请输入你猜的整数：");
            a = sc.nextInt();
            if (a > number) {
                System.out.println("你输入的数字大了");
            } else if (a < number) {
                System.out.println("你输入的数字小了");
            }
        } while (a != number);
    }
}
